
import { data } from "browserslist";
import server from "./server";
export default {

    async getImgBox(name) {
        return await server({
            params: { name: name },
            method: 'get',
            url: '/category/selectSons'
        })
    },

    async getHomeImg(data) {
        return await server({
            method: 'post',
            url: '/photo/getHomePhotos',
            data: data,
        })
    },
    async getAllPhotos() {
        return await server({
            method: 'get',
            url: '/photo/getAllPhotos',
        })
    },
    
    async getPhotos(id, pageNum) {
        return await server({
            method: 'get',
            url: `/photo/selectPhotos/${id}/${pageNum}`
        })
    },

    async getShuffling(){
        return await server({
            method:'get',
            url:'/photo/getShufflingUrls'
        })
    },

    async getPhotoById(id) {
        return await server({
            method: 'get',
            url: `/photo/getPhotoById/${id}`
        })
    },
    async getPhotoByCate(id){
        return await server({
            method: 'get',
            url: `/photo/selectPhotos/${id}/-1`
        })
    },
    async updateApprovalCountsById(data){
        return await server({
            params:data,
            method: 'post',
            url: `/photo/updateApprovalCountsById`
        })
    },

    async insertPhoto(data){
        return await server({
            method:'post',
            url:'/photo/insertPhoto',
            data:data
        })
    },

    // 获取最新图片
    async getNewPhoto() {
        return await server({
            method: 'get',
            url: '/photo/getNewPhoto'
        })
    },
    // 添加图片观看量
    async addPhotoViewCounts(id) {
        return await server({
            method: 'post',
            params: { photoId: id },
            url: `/photo/addPhotoViewCount`
        })
    },

    // 获取用户自己的图片
    async getPhotoByUserId(data) {
        return await server({
            method: 'get',
            params: {
                userid:data.userid,
                pageNum:data.pageNum
            },
            url: `/photo/getPhotosByUserId`
        })
    },
    // 删除用户自己的图片
    async deleteImage(id) {
        return await server({
            method: 'post',
            params: { photoId: id },
            url: `/photo/deletePhoto`
        })
    },
    // 根据名字模糊查询图片
    async getPhotoByName(name) {
        return await server({
            method: 'get',
            url: `/photo/getPhotoByName/` + name
        })
    }
}